// RouterMaster Program for PCMod (CLIENT)

PROG.PName = "RouterMaster"
PROG.Author = "[GU]|ZLC|thomasfn"

PROG.NiceName = "RouterMaster"
PROG.Icon = "icons/ico_ctrl"

function PROG:BuildWindow( WindowName, Desktop, Object )
	//DInterface:AddLabel( "lblInfo", Desktop, "RouterMaster V1", 5, 5 )
	DInterface:AddLabel( "lblInfo2", Desktop, "IP:", 5, 25 )
	DInterface:AddTextbox( "txtIP", Desktop, "192.168.0.1", 25, 25, 100, 20 )
	DInterface:AddButton( "btnBlock", Desktop, "Block", 5, 45, 120, 20, function() SendCommand( "block_ip", DInterface:GetTextboxValue( "txtIP", Desktop ) ); end )
	DInterface:AddButton( "btnUnblock", Desktop, "Unblock", 5, 65, 120, 20, function() SendCommand( "unblock_ip", DInterface:GetTextboxValue( "txtIP", Desktop ) ); end )
	DInterface:AddLabel( "lblData", Desktop, "", 5, 85 )
	DInterface:AddLabel( "lblData2", Desktop, "", 135, 85 )
	
	DInterface:AddLabel( "lblInfo3", Desktop, "Password:", 135, 25 )
	DInterface:AddTextbox( "txtPass", Desktop, "", 190, 25, 100, 20 )
	DInterface:AddButton( "btnGo2", Desktop, "Set", 135, 45, 120, 20, function() SendCommand( "set_pass", DInterface:GetTextboxValue( "txtPass", Desktop ) ); end )
	
	DInterface:AddButton( "btnQuit", Desktop, "X", Object:GetWide()-20, 0, 20, 20, function() SendCommand( "quit" ); end )
end

function PROG:ClearWindow( Desktop )
	DInterface:RemoveLabel( "lblInfo", Desktop )
	DInterface:RemoveLabel( "lblInfo2", Desktop )
	DInterface:RemoveTextbox( "txtIP", Desktop )
	DInterface:RemoveButton( "btnBlock", Desktop )
	DInterface:RemoveButton( "btnUnblock", Desktop )
	DInterface:RemoveLabel( "lblData", Desktop )
	DInterface:RemoveLabel( "lblData2", Desktop )
	
	DInterface:RemoveLabel( "lblInfo3", Desktop )
	DInterface:RemoveTextbox( "txtPass", Desktop )
	DInterface:RemoveButton( "btnGo2", Desktop )
	
	DInterface:RemoveButton( "btnQuit", Desktop )
end

// Data[1] = Tag
// Data[2] = Content
function PROG:DataRecieved( Desktop, Data )
	if (Data[1] == "labelinfo_a") then DInterface:SetLabelText( "lblData", Desktop, Data[2] ) end
	if (Data[1] == "labelinfo_b") then DInterface:SetLabelText( "lblData2", Desktop, Data[2] ) end
end

function PROG:Paint( x, y, w, h )
	draw.SimpleText( self.NiceName, "SmallPCText", x + (w*0.05), y + (h*0.05), Color( 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
end